package WeChat;

import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON;
import com.mulanweb.api.module.model.wechat.Menu;

import java.util.*;

/**
 * Created by Administrator on 2016/8/10.
 */
public class Timer {

    public static void main(String[] args){
         //new Timer(3) ;
        createMenu();
    }

    public Timer(int second){
        java.util.Timer timer = new java.util.Timer() ;
        timer.schedule(new MyTimer(), 0, second*1000);
    }

    private class MyTimer extends TimerTask{
        @Override
        public void run(){
            System.out.print("timetask is run ！");
        }
    }

    public static void createMenu(){
        List<Menu> wxs = new ArrayList<Menu>(3);
        List<Menu> subWxs = new ArrayList<Menu>(5) ;

        Menu menu1 = new Menu();
        menu1.setId(1);
        menu1.setName("现在预定");
        menu1.setType("view");
        menu1.setUrl("http://www.baidu.com");
        wxs.add(menu1);

        Menu menu2 = new Menu();
        menu2.setName("个人中心");

        menu1 = new Menu() ;
        menu1.setName("订单列表");
        menu1.setUrl("http://www.hao123.com");
        menu1.setId(2);
        menu1.setKey("test");
        menu1.setType("click");
        subWxs.add(menu1);
        menu2.setSub_button(subWxs);
        wxs.add(menu2);
        Map<String,Object> tt = new HashMap<String,Object>();
        tt.put("button",wxs) ;
        System.out.println(JSON.toJSONString(tt));
    }
}
